package com.scar1et.strategy.context;

import com.scar1et.strategy.promotion.CashNormal;
import com.scar1et.strategy.promotion.CashRebate;
import com.scar1et.strategy.promotion.CashReturn;
import com.scar1et.strategy.promotion.CashSuper;

/**
 * 上下文关系
 * Created by scar1et on 15-10-26.
 */
public class CashContext {
    private CashSuper promotion;

    public CashContext(String type) throws Exception {
        switch (type) {
            case "normal":
                promotion = new CashNormal();
                break;
            case "rebate":
                promotion = new CashRebate();
                break;
            case "return":
                promotion = new CashReturn();
                break;
            default:
                throw new Exception("不支持的促销活动");
        }
    }

    public void getResult() {
        promotion.acceptCash();
    }
}
